package file;

import java.io.File;
import java.io.IOException;

public class FileDemo1 {
    public static void main(String[] args) throws IOException {
        File f1=new File("G:\\desktop\\use2.txt");
        //创建文件f1
        f1.createNewFile();
        System.out.println(f1);
        File f2=new File("G:\\desktop\\use.txt");
        System.out.println("f2文件是否存在:"+f2.exists());
        System.out.println(f2);
//        父级路径、子级路径
        File f3=new File("G:\\desktop","use.txt");
        System.out.println(f3);
        File f4=new File(new File("G:\\desktop","use.txt").toURI());
        System.out.println(f4);
//         打印项目所在路径
        File f=new File("");
        System.out.println(" 项目所在路径："+f.getAbsoluteFile());
        File f5=new File("file\\use.txt");
        f5.createNewFile();
        System.out.println(f5);
        System.out.println(f5.getAbsoluteFile());

    }
}
